<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<title>信用卡推广</title>
		<link rel="stylesheet" type="text/css" href="css/public.css"/>
	</head>
	<style type="text/css">
		body img{width: 7.5rem;height: 12.2rem;display: block;}
		#bg{width: 7.5rem;height: 12.2rem;display: block;}
		#erCode{position: absolute;text-align: center;}
		/*民生银行*/
		.msbox{height: 3.78rem;width: 3.7rem;top: 4rem;left: 1.5rem;padding: 0.1rem;}
		.msercode{height: 3.78rem !important;width: 3.6rem !important;margin-left: 0.12rem;}
		.msname{font-size: 0.34rem;position: absolute;top: 8.73rem;left: 1.75rem;}
		.mstel{font-size: 0.32rem;color: #0071bc;position: absolute;top: 11rem;left: 4.65rem;}
		/*交通银行*/
		.jtbox{height: 3rem;width: 3rem;top: 4.95rem;left: 1.85rem;padding: 0.1rem;}
		.jtercode{height: 3.25rem;width: 3.1rem;}
		.jtname{font-size: 0.4rem;position: absolute;top:10rem;left: 1.65rem;}
		.jttel{font-size: 0.4rem;color: #000;position: absolute;top: 11rem;left: 1.4rem;}
		/*招商银行*/
		.zsyhbox{height: 3rem;width: 3rem;top: 5.4rem;left: 2.02rem;padding: 0.1rem;}
		.zsyhercode{height: 3.25rem;width: 3.1rem;}
		.zsyhname{font-size: 0.4rem;position: absolute;top:10rem;left: 1.65rem;}
		.zsyhtel{font-size: 0.4rem;color: #fd0e02;position: absolute;top: 11rem;left: 1.4rem;}
		/*浦发银行*/
		.pfbox{height: 3.2rem;width: 3.2rem;top: 4rem;left: 2.02rem;padding: 0.1rem;}
		.pfercode{height: 3.43rem;width: 3.3rem;}
		.pfname{font-size: 0.4rem;position: absolute;top:9rem;left: 1.65rem;}
		.pftel{font-size: 0.4rem;color: #fd0e02;position: absolute;top: 10rem;left: 1.4rem;}
		/*兴业银行*/
		.xybox{height: 3.2rem;width: 3.2rem;top: 5.12rem;left: 1.95rem;padding: 0.1rem;}
		.xyercode{height: 3.2rem;width: 3.1rem;}
		.xyname{font-size: 0.4rem;position: absolute;top:10rem;left: 1.65rem;}
		.xytel{font-size: 0.4rem;color: #000;position: absolute;top: 11.3rem;left: 1.4rem;}
		/*光大银行*/
		.gdbox{height: 3.2rem;width: 3.2rem;top: 5.22rem;left: 1.87rem;padding: 0.1rem;}
		.gdercode{height: 3.2rem;width: 3.12rem;}
		.gdname{font-size: 0.4rem;position: absolute;top:10rem;left: 1.65rem;}
		.gdtel{font-size: 0.4rem;color: #fd0e02;position: absolute;top: 11rem;left: 1.4rem;}
		/*平安银行*/
		.pabox{height: 3.11rem;width: 3.11rem;top: 4.78rem;left: 2.2rem;padding: 0.1rem;}
		.paercode{height: 3.2rem;width: 3.11rem;}
		.paname{font-size: 0.4rem;position: absolute;top:9.5rem;left: 1.7rem;}
		.patel{font-size: 0.4rem;color: #fd0e02;position: absolute;top: 10.5rem;left: 1.45rem;}
		/*中信银行*/
		.zxbox{height: 3.11rem;width: 3.11rem;top: 4.75rem;left: 2.2rem;padding: 0.1rem;}
		.zxercode{height: 3.2rem;width: 3.11rem;}
		.zxname{font-size: 0.4rem;position: absolute;top:9.5rem;left: 1.7rem;}
		.zxtel{font-size: 0.4rem;color: #fd0e02;position: absolute;top: 10.5rem;left: 1.45rem;}
		/*广发银行*/
		.gfbox{height: 3.11rem;width: 3.11rem;top: 5.2rem;left: 1.93rem;padding: 0.1rem;}
		.gfercode{height: 3.24rem;width: 3.11rem;}
		.gfname{font-size: 0.4rem;position: absolute;top:10rem;left: 1.7rem;}
		.gftel{font-size: 0.4rem;color: #fd0e02;position: absolute;top: 11rem;left: 1.45rem;}
		/*上海银行*/
		.shbox{height: 3.11rem;width: 3.11rem;top: 5.25rem;left: 2.18rem;padding: 0.1rem;}
		.shercode{height: 3.22rem;width: 3.11rem;}
		.shname{font-size: 0.4rem;position: absolute;top:10.2rem;left: 1.7rem;color: #336699;}
		.shtel{font-size: 0.4rem;color: #fff;position: absolute;top: 11.25rem;left: 1.45rem;}
		/*浙商银行*/
		.zsbox{height: 3.11rem;width: 3.11rem;top: 5.3rem;left: 1.9rem;padding: 0.1rem;}
		.zsercode{height: 3.22rem;width: 3.11rem;}
		.zsname{font-size: 0.4rem;position: absolute;top:10.2rem;left: 1.7rem;}
		.zstel{font-size: 0.4rem;color: #fff;position: absolute;top: 11.25rem;left: 1.45rem;}
		/*工商银行*/
		.gsbox{height: 3.2rem;width: 3.11rem;top: 4.77rem;left: 2.1rem;padding: 0.1rem;}
		.gsercode{height: 3.2rem;width: 3.14rem;}
		.gsname{font-size: 0.4rem;position: absolute;top:9.65rem;left: 1.85rem;color: #4a5353;}
		.gstel{font-size: 0.4rem;color: #fd0e02;position: absolute;top: 10.6rem;left: 1.6rem;}
	</style>
	<body>
		<div class="container">
			<img src="img/bg.jpg" id='bg'/>
			<div id="erCode">	
			</div>
			<p id="name"></p>
			<p id="phone"></p>
		</div>
	</body>
	<script type="text/javascript" src="js/zepto.js"></script>
	<script type="text/javascript" src="js/layer.js"></script>
	<script type="text/javascript" src="js/rem.js"></script>
	<script type="text/javascript" src="js/html2canvas.js"></script>
	<script type="text/javascript" src="js/qrcode.min.js"></script>
	<script type="text/javascript" src="js/api.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
	<script type="text/javascript">
	$(function(){
		const url = Util.GetQueryString('url');			
		const targetId = Util.GetQueryString('targetId');
		const type = Util.GetQueryString('type');
		const userId = Util.GetQueryString('userId');
		var ua= navigator.userAgent.toLowerCase();
		//微信浏览器
		if(ua.match(/MicroMessenger/i)=="micromessenger") {
			const datap = {
					userId:userId
				};
					$.ajax({
					type : 'POST',
					url : 'http://www.uniao.me/app/user/info.htm',
					data: JSON.stringify(datap),
					contentType : 'application/json; charset=utf-8',
					dataType: 'json',
					success: function(res){
					if(res.code == 200){
							var shareUrl = 'http://www.uniao.me/app/advertis/loancard/apply.htm?url='+ url +'&userId='+ userId +'&type='+ type +'&targetId='+ targetId +'';
							var qrcode = new QRCode("erCode", { //生成带参二维码
								    text: shareUrl,
								    colorDark : "#000000",
								    colorLight : "#ffffff",
								    correctLevel : QRCode.CorrectLevel.Q
							});	
							switch(targetId){
								//民生银行推荐办卡
								case '19': 
								$('#bg').attr('src','img/mingsheng.jpg');
								$('#erCode').addClass('msbox');
								$('#erCode').children('img').addClass('msercode');
								$('#erCode').children('canvas').addClass('msercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('msname');
								$('#phone').text(res.data.phone).addClass('mstel');
								break;
								
								//交通银行推荐办卡
								case '12':
								$('#bg').attr('src','img/jiaotong.jpg');
								$('#erCode').addClass('jtbox');
								$('#erCode').children('img').addClass('jtercode');
								$('#erCode').children('canvas').addClass('jtercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('jtname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('jttel');
								break;
								
								//招商银行推荐办卡
								case '17':
								$('#bg').attr('src','img/zhaoshang.jpg');
								$('#erCode').addClass('zsyhbox');
								$('#erCode').children('img').addClass('zsyhercode');
								$('#erCode').children('canvas').addClass('zsyhercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('zsyhname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('zsyhtel');
								break; 
								
								//浦发银行推荐办卡
								case '18':
								$('#bg').attr('src','img/pufa.jpg');
								$('#erCode').addClass('pfbox');
								$('#erCode').children('img').addClass('pfercode');
								$('#erCode').children('canvas').addClass('pfercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('pfname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('pftel');
								break; 
								
								//新业银行推荐办卡
								case '20':
								$('#bg').attr('src','img/xinye.jpg');
								$('#erCode').addClass('xybox');
								$('#erCode').children('img').addClass('xyercode');
								$('#erCode').children('canvas').addClass('xyercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('xyname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('xytel');
								break;
								
								//光大银行推荐办卡
								case '27':
								$('#bg').attr('src','img/guangda.jpg');
								$('#erCode').addClass('gdbox');
								$('#erCode').children('img').addClass('gdercode');
								$('#erCode').children('canvas').addClass('gdercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('gdname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('gdtel');
								break; 
								
								//平安银行推荐办卡
								case '28':
								$('#bg').attr('src','img/pingan.jpg');
								$('#erCode').addClass('pabox');
								$('#erCode').children('img').addClass('paercode');
								$('#erCode').children('canvas').addClass('paercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('paname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('patel');
								break;
								
								//中信银行推荐办卡
								case '29':
								$('#bg').attr('src','img/zhongxin.jpg');
								$('#erCode').addClass('zxbox');
								$('#erCode').children('img').addClass('zxercode');
								$('#erCode').children('canvas').addClass('zxercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('zxname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('zxtel');
								break;
								
								//广发银行推荐办卡
								case '30':
								$('#bg').attr('src','img/guangfa.jpg');
								$('#erCode').addClass('gfbox');
								$('#erCode').children('img').addClass('gfercode');
								$('#erCode').children('canvas').addClass('gfercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('gfname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('gftel');
								break; 
								
								//上海银行推荐办卡
								case '31':
								$('#bg').attr('src','img/shanghai.jpg');
								$('#erCode').addClass('shbox');
								$('#erCode').children('img').addClass('shercode');
								$('#erCode').children('canvas').addClass('shercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('shname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('shtel');
								break;
								
								//浙江银行推荐办卡
								case '32':
								$('#bg').attr('src','img/zeshang.jpg');
								$('#erCode').addClass('zsbox');
								$('#erCode').children('img').addClass('zsercode');
								$('#erCode').children('canvas').addClass('zsercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('zsname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('zstel');
								break; 
								
								//中信银行2推荐办卡
								case '33':
								$('#bg').attr('src','img/zhongxin.jpg');
								$('#erCode').addClass('zxbox');
								$('#erCode').children('img').addClass('zxercode');
								$('#erCode').children('canvas').addClass('zxercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('zxname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('zxtel');
								break;
								
								//工商银行推荐办卡
								case '37':
								$('#bg').attr('src','img/gsyh.jpg');
								$('#erCode').addClass('gsbox');
								$('#erCode').children('img').addClass('gsercode');
								$('#erCode').children('canvas').addClass('gsercode');
								$('#name').html('客户经理：<span style="font-size: 0.6rem;">&nbsp;'+ res.data.userName +'</span>').addClass('gsname');
								$('#phone').text('联系电话：'+res.data.phone).addClass('gstel');
								break;
							}
							function convertCanvasToImage(canvas) {
								　　var image = new Image();
								　　image.src = canvas.toDataURL("image/png"); 
								　　return image; 
							}	
								var w = $(".container").width();
							    var h = $(".container").height();
							    //要将 canvas 的宽高设置成容器宽高的 2 倍
							    var canvas = document.createElement("canvas");
							    canvas.width = w*4;
							    canvas.height = h*4;
							    canvas.style.width = w + "px";
							    canvas.style.height = h + "px";
							    var context = canvas.getContext("2d");
							    //然后将画布缩放，将图像放大两倍画到画布上
							    context.scale(4,4);
							    html2canvas(document.querySelector(".container"), {
							      canvas: canvas,
							      onrendered: function (canvas) {
							      	var img=convertCanvasToImage(canvas);
										$('body').html('');
										$('body').html(img);
							      }
							    });
					}
				}
			})
		 }else{
	//		 	Util.jump(Host+'/app/advertis/loancard/apply.htm?&url='+url+'&userId='+userId+'&type=1&targetId='+targetId);
				Util.jump(url);
		 }
		});
	</script>
</html>
